{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}

{% block toolbar %}
    {% set icon %}
        <img width="20" height="28" alt="Database" style="border-width: 0; vertical-align: middle; margin-right: 5px;" src=""/>
    {% endset %}
    {% set text %}
        <span title="{{ '%0.2f'|format(collector.time * 1000) }} ms">{{ collector.querycount }}</span>
    {% endset %}
    {% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}
{% endblock %}

{% block menu %}
<span class="label">
    <span class="icon"><img src="{{ asset('bundles/webprofiler/images/profiler/db.png') }}" alt="" /></span>
    <strong>Doctrine</strong>
    <span class="count">
        <span>{{ collector.querycount }}</span>
        <span>{{ '%0.0f'|format(collector.time * 1000) }} ms</span>
    </span>
</span>
{% endblock %}

{% block panel %}
    <h2>Queries</h2>

    {% if not collector.querycount %}
        <p>
            <em>No queries.</em>
        </p>
    {% else %}
        <ul class="alt">
            {% for i, query in collector.queries %}
                <li class="{{ i is odd ? 'odd' : 'even' }}">
                    <div>
                        <code>{{ query.sql }}</code>
                    </div>
                    <small>
                        <strong>Parameters</strong>: {{ query.params|yaml_encode }}<br />
                        <strong>Time</strong>: {{ '%0.2f'|format(query.executionMS * 1000) }} ms
                    </small>
                </li>
            {% endfor %}
        </ul>
    {% endif %}

    <h2>Database Connections</h2>

    {% if collector.connections %}
        <table>
            <tr>
                <th>Name</th>
                <th>Service</th>
            </tr>
            {% for name, service in collector.connections %}
                <tr>
                    <th>{{ name }}</th>
                    <td>{{ service }}</td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        <p>
            <em>No entity managers.</em>
        </p>
    {% endif %}

    <h2>Entity Managers</h2>

    {% if collector.managers %}
        <table>
            <tr>
                <th>Name</th>
                <th>Service</th>
            </tr>
            {% for name, service in collector.managers %}
                <tr>
                    <th>{{ name }}</th>
                    <td>{{ service }}</td>
                </tr>
            {% endfor %}
        </table>
    {% else %}
        <p>
            <em>No entity managers.</em>
        </p>
    {% endif %}
{% endblock %}
